<template>
	<view class="container">
		<!-- 顶部导航栏 -->
		<view class="top-nav">
			<view class="tabs">
				<text class="tab" :class="{ active: activeTab === 'current' }" @click="activeTab = 'current'">
					当前工单
				</text>
				<text class="tab" :class="{ active: activeTab === 'history' }" @click="activeTab = 'history'">
					历史工单
				</text>
			</view>
			<view class="add-btn" @click="goApplyOrder">
				<text class="plus-icon">＋</text>
			</view>
		</view>

		<!-- 内容区域 -->
		<view class="tab-content">
			<component :is="activeComponent" />
		</view>
	</view>
</template>


<script>
	import OrderList from '../../../components/orderList/orderList.vue';
	import HistoryOrder from '../../../components/historyOrder/historyOrder.vue';
	export default {
		data() {
			return {
				isAuthorization: true,
				token: null,
				activeTab: 'current'
			};
		},
		components: {
			OrderList,
			HistoryOrder

		},
		computed: {
			activeComponent() {
				return this.activeTab === 'current' ? 'OrderList' : 'HistoryOrder';
			}
		},
		onLoad() {
			this.checkLoginStatus();
		},
		methods: {
			checkLoginStatus() {
				const token = uni.getStorageSync('token');
				if (token) {
					this.token = token;
					this.isAuthorization = false;
				}
			},
			goApplyOrder() {
				uni.navigateTo({
					url: '/pages/user/apply/apply'
				});
			}
		}
	};
</script>

<style scoped>
	.container {
		background-color: #f3f5f9;
		min-height: 100vh;
		position: relative;
		/* ⬇⬇⬇ 关键修复点：让出顶部固定导航栏的空间 */
		padding-top: 50px;
	}

	/* 顶部导航 */
	.top-nav {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		background-color: #3a7afe;
		padding: 12px 16px 16px;
		border-bottom-left-radius: 12px;
		border-bottom-right-radius: 12px;
		box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
		z-index: 10;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.tabs {
		display: flex;
		background-color: white;
		padding: 4px;
		border-radius: 20px;
		box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
	}

	.tab {
		padding: 6px 16px;
		border-radius: 20px;
		font-size: 14px;
		color: #3a7afe;
		font-weight: 500;
	}

	.tab.active {
		background-color: #3a7afe;
		color: white;
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	}

	/* + 按钮 */
	.add-btn {
		position: absolute;
		right: 16px;
		top: 12px;
		width: 30px;
		height: 30px;
		background-color: white;
		border-radius: 50%;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.plus-icon {
		color: #3a7afe;
		font-size: 20px;
		line-height: 1;
	}

	/* 内容区 */
	.tab-content {
		padding: 20px;
	}

	.tab-panel {
		display: flex;
		justify-content: center;
		align-items: center;
		min-height: 200px;
		background: white;
		border-radius: 12px;
		box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
		padding: 20px;
	}

	.placeholder {
		color: #666;
		font-size: 16px;
	}
</style>